package com.qn.servicelocator.news;

import com.qn.servicelocator.ContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NewClient {
    private ParserFactory parserFactory;

    @Autowired
    public NewClient(ParserFactory parserFactory) {
        this.parserFactory = parserFactory;
    }

    public String getAll(ContentType contentType) {
        // 关键点，直接根据类型获取
        return parserFactory
                .getParser(contentType)
                .parse();
    }
}